import { Injectable } from '@angular/core';
import { BaseService } from './base.service';

@Injectable({
  providedIn: 'root'
})
export class UploadService extends BaseService {
  uploadAction = `${this.remoteAddress}/api/rescoure/file`;
  upload(formData: FormData) {
    const url = `api/rescoure/file`
    return this.post(url, formData)
  }

  getFiles(dir) {
    let url = `api/rescoure/file`;
    let orgId = localStorage.getItem('orgid');
    return this.get(url, {
      params: {
        orgId,
        dir
      }
    })
  }

  delFiles(fileName, file) {
    let url = `api/rescoure/file`;
    let orgId = localStorage.getItem('orgid');
    fileName = fileName + '/' + file
    return this.delete(url, {
      params: {
        orgId,
        fileName,
      }
    })
  }

  delFileByName(fName: string) {
    let url = `api/rescoure/file`;
    return this.delete(url, {
      params: {
        completeFname: fName,
      }
    })
  }



}
